<!-- 团奖申请财务 -->
<template>
	<div>
		<el-form :inline="true" :model="ruleForm" class="demo-form-inline" style="width:92%">
			<el-form-item label="城市：">
			    <el-select v-model="ruleForm.cityId" filterable >
			        <el-option v-for="item in citys"
			                   :key="item.cityId"
			                   :label="item.city"
			                   :value="item.cityId">
			        </el-option>
			    </el-select>
			</el-form-item>
			<el-form-item label="楼盘：">
				<el-select v-model="ruleForm.devId" filterable >
				    <el-option v-for="(item,index) in estateslist"
				               :key="index"
				               :label="item.devName"
				               :value="item.devId">
				    </el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="时间：">
				<el-date-picker
					v-model="time"
					type="datetimerange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item>
			<el-form-item label="审核状态：">
			    <el-select v-model="ruleForm.approvalStatus" filterable >
			        <el-option v-for="item in auditlist"
			                   :key="item.id"
			                   :label="item.label"
			                   :value="item.id">
			        </el-option>
			    </el-select>
			</el-form-item>
			<el-form-item label="批次号">
				<el-input v-model="ruleForm.batchCode" placeholder="批次号"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary"  @click="searchList" id="monitorEnter">查询</el-button>
				<el-button  @click="resethander">重置</el-button>
			</el-form-item>
		</el-form>
	
		<el-table :data="tableData" border style="width: 100%" ref="multipleTable">
			<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
			<el-table-column label="城市" prop="cityName" align="center"></el-table-column>
			<el-table-column label="楼盘名称" prop="devName" align="center"></el-table-column>
			<el-table-column label="批次号" prop="batchCode" align="center"></el-table-column>
			<el-table-column label="订单数" prop="orderCount" align="center"></el-table-column>
			<el-table-column label="发放方式" prop="settleCommMode" align="center">
				<template slot-scope="scope">
					<span v-if="scope.row.settleCommMode==0">购物卡</span>
					<span v-if="scope.row.settleCommMode==1">第三方</span>
					<span v-if="scope.row.settleCommMode==2">劳务所得</span>
				</template>
			</el-table-column>
			<el-table-column label="应发团奖(税前)" prop="shouldTeamReward" :formatter="initCash" align="center"></el-table-column>
			<el-table-column label="税率%" prop="taxRate" align="center"></el-table-column>
			<el-table-column label="应扣税费" prop="shouldDeductTax" :formatter="initCash" align="center"></el-table-column>
			<el-table-column label="应发团奖(税后）" :formatter="initCash" prop="shouldTeamRewardAfterTax" align="center"></el-table-column>
			<el-table-column label="应扣服务费" :formatter="initCash" prop="shouldDecuctFee" align="center">
			</el-table-column>
			<el-table-column label="实发团奖" :formatter="initCash" prop="actualTeamReward" align="center"></el-table-column>
			<el-table-column label="审核状态" prop="approvalStatus" align="center">
				<template  slot-scope="scope">
					<span v-if="scope.row.approvalStatus==1">审核中</span>
					<span v-if="scope.row.approvalStatus==2">审核通过</span>
					<span v-if="scope.row.approvalStatus==3">审核拒绝</span>
				</template>
			</el-table-column>
			<el-table-column label="提交人" prop="applyUserName" align="center"></el-table-column>
			<el-table-column label="提交时间" prop="createTime" align="center"></el-table-column>
			<el-table-column label="操作" align="center">
			    <template slot-scope="scope">
					<el-button type="text" :disabled="scope.row.approvalStatus !== 1" @click="$router.push({path: '/groupAwardApplyFinanceAudit',query:{id:scope.row.id}})">审核</el-button>
			    </template>
			</el-table-column>
		</el-table>

		<div class="pagebar">
		    <el-pagination
		            background
		            layout="total, sizes, prev, pager, next"
		            :current-page.sync="ruleForm.pageNum"
		            :page-sizes="[10, 20, 30, 40]"
		            :page-size="ruleForm.pageSize"
		            @size-change="handleSizeChange"
		            @current-change="handleCurrentChange"
		            :total="totalSize">
		    </el-pagination>
		</div>
	</div>
</template>

<script>
	import api from '@/api/apiPath'
	import utils from "@/common/utils.js";
	export default {
		name:'groupAwardApplyFinance',
		title:'团奖申请-财务',
	    data() {
	        return {
	        	citys:[],
	        	estateslist:[],
	        	tableData:[],
	        	time:undefined,
	        	auditlist:[
	        		{id:1,label:'审核中'},
	        		{id:2,label:'审核通过'},
	        		{id:3,label:'审核拒绝'},
	        		{id:4,label:'未审核'},
	        	],
	        	ruleForm:{
	        		batchCode:'',
	        		startTime:undefined,
	        		endTime:undefined,
	        		cityId:undefined,
	        		devId:undefined,
	        		approvalStatus:undefined,
	        		pageNum: 0,
	        		pageSize: 10,
	        	},
	        	totalSize: 0,
	        }
	    },
		activated(){
			this.searchList()
		},
	    created(){
	    	this.loadCity()
	    	this.getlist()
	    	this.allestate()
	    },
	    methods:{
	    	resethander(){
	    		this.ruleForm.cityId = ''
	    		this.ruleForm.devId = ''
	    		this.time = []
	    		this.ruleForm.startTime =''
	    		this.ruleForm.endTime = ''
	    		this.ruleForm.approvalStatus =''
	    		this.ruleForm.batchCode =''
	    	},
			allestate(){
				this.axios.post(api.ALLESTATEDEVS,{}).then(res=>{
					if (res.data.code == 200) {
						this.estateslist = res.data.data
					}
				})
			},
	    	initCash(row, column, cellValue, index){
	    		if (!cellValue && cellValue !== 0) {
	    		    return '——'
	    		}
	    	    if(cellValue !== 0){
	    	        return cellValue.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");
	    	    }
	    	    if(cellValue == 0){
	    	        return "0.00"
	    	    }
	    	},
	    	getlist(){
	    		this.axios.post(api.GETTEAMREWARDAPPLYLISTFINANCE,this.ruleForm).then(res=>{
					if (res.data.code == 200) {
						this.tableData = res.data.data.list
						this.totalSize = res.data.data.total
					}
	    		})
	    	},
	    	handleCurrentChange() {
	    	    this.getlist()
	    	},
	    	handleSizeChange(val) {
	    	    this.ruleForm.pageSize = val
	    	    this.getlist();
	    	},
	    	searchList(){
	    		this.ruleForm.pageNum = 1
	    		if (this.time) {
					this.ruleForm.startTime =  utils.getTimeString(this.time[0])
					this.ruleForm.endTime = utils.getTimeString(this.time[1])	
	    		}
	    		this.getlist();
	    	},
	    	loadCity(){
	    		this.axios.post(api.CITYLIST).then(res => {
	    			if (res.data.code !== 200) {
	    				this.$message(res.data.msg)
	    			}else {
	    				this.citys = res.data.data.cityList
	    			}
	    		})
	    	},

	    }
	}
</script>
<style lang="stylus">
	

</style>